package com.banach.prema.repository;


import com.banach.prema.dto.vo.ContactVO;
import com.banach.prema.repository.mapper.ContactMapper;
import com.banach.prema.repository.dataobject.ContactDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ego.framework.core.tookit.BeanToolkit;
import com.ego.framework.jdbc.repository.BaseRepository;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ContactRepository extends BaseRepository<ContactMapper, ContactDO, ContactVO> {

    public List<ContactVO> selectByUserId(Long userId){
        LambdaQueryWrapper<ContactDO> queryWrapper = Wrappers.<ContactDO>lambdaQuery()
                .eq(ContactDO::getUserId, userId);
        List<ContactDO> contacts = this.baseMapper.selectList(queryWrapper);
        return BeanToolkit.getInstance().copyList(contacts, ContactVO.class);
    }

}
